<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="icon" href="../../logo.svg" />
    <title>vue</title>
  </head>
  <body>
    <div id="root"></div>

    <script src="../../vue.js"></script>
    <script>
      Vue.config.productionTip = false; // 阻止 vue 在启动时生成生产提示。

      // 简写方式
      const Student = {
        template: `<div>
          <h2>学生姓名：{{name}}</h2>
          <h2>学生年龄：{{age}}</h2>
          </div>`,
        data() {
          return {
            name: "张三",
            age: 29,
          };
        },
      };

      const School = Vue.extend({
        template: `<div>
            <h2>学校名称：{{name}}</h2>
            <h2>学校地址：{{address}}</h2>
            <hr />
            <Student></Student>
          </div>`,
        data() {
          return {
            name: "非正常人类研究院",
            address: "火星",
          };
        },
        components: { Student },
      });

      const Hello = Vue.extend({
        template: `<h1>你好，世界！</h1>`,
      });

      const App = Vue.extend({
        template: `<div>
            <Hello></Hello>
            <School></School>
          </div>`,
        components: { School, Hello },
      });

      new Vue({
        el: "#root",
        template: `<App></App>`,
        components: { App },
      });
    </script>
  </body>
</html>
